#override("title")
SpringWind - 场地列表
#end
#override("css")
<link href="#springUrl('/static/css/plugins/bootstrap-table/bootstrap-table.min.css')" rel="stylesheet">

#end
#override("breadcrumb")
<li><a>评分系统</a></li><li class="active"><strong>场地列表</strong></li>
#end
#override("content")
<div class="row">
<!--    <input type="hidden" name="provinceId" value="$!{provinceId}">
    <input type="hidden" name="cityId" value="$!{cityId}">
    <input type="hidden" name="province" value="$!{province}">
    <input type="hidden" name="city" value="$!{city}">-->
	<div class="ibox-content text-left form-inline" style="background: #F3F3F4;">
		<div class="input-group">
			<label class="text-left">场地id:<input type="text" class="" id="sid"></label>
		</div>&nbsp;
		<div class="input-group">
			<label  class="text-left">场地名称:<input type="text" class="" id="sName"></label>
		</div>
		<div class="input-group">
			<button type="button" class="btn btn-info" id="querySite" onclick="querySource($('#sid').val(),$('#sName').val())">查询</button>
		</div>
		<!--<div class="input-group">
             <a id="addSite" class="btn btn-primary"  title="添加">添加</a>
		</div>-->
	</div>

</div>
<div class="row">
    <div class="col-sm-12">
        <table id="dataTable"></table>
    </div>
</div>
#end
#override("js")
<script src="#springUrl('/static/js/plugins/bootstrap-table/bootstrap.min.js')"></script>
<script src="#springUrl('/static/js/plugins/bootstrap-table/bootstrap-table.min.js')"></script>
<script src="#springUrl('/static/js/plugins/bootstrap-table/locale/bootstrap-table-zh-CN.min.js')"></script>
<script src="#springUrl('/static/plugins/layer-v2.2/layer/layer.js')"></script>
<script src="#springUrl('/static/js/base_list.js')"></script>
<script src="#springUrl('/static/js/common.js')"></script>
<script type="text/javascript">
 //var  province=$("input[name='provinceId']").val();
// var city=$("input[name='cityId']").val();
 //var dataUrl="#springUrl('/site/getSiteList/530000/532300')";


 var dataUrl="#springUrl('/examine/getSiteList')";

// alert(dataUrl);
 /*var data = $('#dataTable').bootstrapTable('getData');*/
 var dataColumns = [{
		field: 'id',
		title: '场地编号'
	}, {
		field: 'siteName',
		title: '场地名称'
	}, {
		field: 'province',
		title: '省份'
	}, {
		 field: 'city',
		 title: '城市'
 	}, {
		 field: 'dist',
		 title: '区/县'
 	}, {
         field: 'audit_time',
         title: '提交时间',
         formatter: function (value, row, index) {
             return formatDate(row.audit_time);
         }
    }, {
		 field: 'status',
		 title: '状态',
		 formatter: function (value, row, index) {
			 if(row.status==2){
			     return '<span style="color: red">待审批</span>';
			 }else if(row.status==3){
			     return '<span style="color: green">审批通过</span>';
			 }else if(row.status==-1){
                 return '<span style="color: blue">审批不通过</span>';
             }
		 }
 	}, {
    title: '详情',
    formatter: function (value, row, index) {
        var id = row.id;
        return '<a class="btn btn-xs btn-warning" title="详细信息"  href="#springUrl("/examine/details/' + id +'")"><i class="fa fa-pencil"></i>场地信息</a> '
                +'<a class="btn btn-xs btn-success" href="#springUrl("/siteSource/view/' + id +'")"><i class="fa fa-edit"></i>分数统计</a>'
                +'<a class="btn btn-xs btn-info" href="#springUrl("/examine/source/' + id +'/0'+'")"><i class="fa fa-pencil"></i>详细信息</a> '
            //    +'<a class="btn btn-xs btn-danger" href="#springUrl("/examine/ground/' + id+'/0' +'")"><i class="fa fa-remove"></i>污染途径</a> ';
             //  + '<a class="btn btn-xs btn-danger" onclick="delSite(' + "'" + id + "'" + ')"><i class="fa fa-remove"></i>删除</a>';
    }
	}, {
     title: '审批',
     formatter: function (value, row, index) {
         var id = row.id;
         if(row.status==2){
             return '<a class="btn btn-xs btn-primary" onclick="examine('+id+',true)"><i class="fa fa-check"></i>通过</a>'
                 +'<a class="btn btn-xs btn-danger" onclick="examine('+id+',false)"><i class="fa fa-remove"></i>不通过</a>';
		 }else {
			 return '<div style="color: green;text-align: center">已审批</div>';
		 }
     }
 }];
function dataQueryParams(params) {
	return {
		_size: params.limit,  //页面大小
		_index: params.offset, //页码
		sid:$('#sid').val(),
		name:$('#sName').val(),
       /* province:province,
		city:city*/
	};
}
function SiteDetail() {
    var title = "分数评比";
    var url = "#springUrl('/examine/details.html')";
    layer.open({
        type: 2,
        title: title,
        shadeClose: true,
        shade: 0.8,
        area: ['600px', '480px'],
        fix: false,
        maxmin: true,
        content: url
    });
}
/*function delSource(id) {
    //询问框
    layer.confirm('确定删除吗？', {
        btn: ['确定', '取消'] //按钮
    }, function () {
        $.ajax({
            type: "POST",
            url: "#",
            datatype: "text",
            success: function (data) {
                if(data == 'true'){
                    $('#dataTable').bootstrapTable('refresh',{url:dataUrl});
                }
                layer.closeAll();
            }
        });
    }, function () {
        return;
    });
}*/

//通过审核
 function examine(id,flag) {
     layer.open({
         type: 1,
		 title:'审批意见',
         // skin: 'layui-layer-rim', //加上边框
         area: ['450px', '270px'], //宽高
         btn: ['提交','取消'], //按钮
         content: '<textarea id="idea" style="height: 100%;width: 100%;border: none"></textarea>',
         yes: function(index, layero){
             var idea = $('#idea').val();
             $.ajax({
                 type: 'POST',
                 url: "#springUrl('/examine/examine')",
                 data: $.param({'id':id,'idea':idea,'flag':flag}),
                 success: function (data) {
                     var d = JSON.parse(data);
                     if(d.data == true){
                         parent.layer.alert("审批成功",function(){
                             parent.layer.closeAll();
                             window.parent.location.reload();
                         });
					 }else {
                         parent.layer.alert("审批失败",function(){
                             parent.layer.closeAll();
                         });
					 }
                 },
				 error:function (data) {
                     parent.layer.alert("服务器错误",function(){
                         parent.layer.closeAll();
                        // window.parent.location.reload();
                     });
                 },
                 datatype: 'json'
             });
             layer.close(index); //如果设定了yes回调，需进行手工关闭
         }
     });
 }

 //查询功能
 function querySource(id,name) {
     $('#dataTable').bootstrapTable('refresh',{
         url:"#springUrl('/examine/querySiteList')"
	 });

 }

/*!function () {
   /!* var provinceId=$("input[name='provinceId']").val();
    var cityId=$("input[name='cityId']").val();
    $('#addSite').attr('href','#springUrl("/site/add/'+provinceId+'/'+cityId+'")');*!/
}();*/
function editSource(id) {
   	var title = "查看场地";
   	var url = "#springUrl('/site/edit.html')";
   	if(id!=null){
   		url = url + "?id=" + id;
   	}
    layer.open({
        type: 2,
        title: title,
        shadeClose: true,
        shade: 0.8,
        area: ['550px', '430px'],
        fix: false,
        maxmin: true,
        content: url
    });
}
/*
 function delSite(siteId) {
     //询问框
     layer.confirm('确定删除吗？', {
         btn: ['确定', '取消'] //按钮
     }, function () {
         $.ajax({
             type: "POST",
             url: "#springUrl('/site/delSite/')" + siteId,
             datatype: "text",
             success: function (data) {
                 if(data == 'true'){
                     $('#dataTable').bootstrapTable('refresh',{url:dataUrl});
                 }
                 layer.closeAll();
             }
         });
     }, function () {
         return;
     });
 }
*/


</script>
#end
#extends("/common/framework.html")
